import App from './App'
import Vue from 'vue'
import store from '@/common/utils/store'
import env from "@/common/utils/env.js"
import * as utils from '@/common/utils/index.js'
// 水印
import watermark from '@/common/utils/watermark.js'
// 网络请求
import {
    api,
    login
} from '@/common/utils/request'

// element ui
import ElementUI, {
    Message,
    Notification
} from 'element-ui';
// css样式引入
import 'element-ui/lib/theme-chalk/index.css'
import '@/static/css/houseDetail.css'

let dayjs = require('dayjs')
let localforage = require('localforage');
// 路由
import {
    router,
    RouterMount
} from '@/common/AppRouter.js';

Vue.use(ElementUI)
Vue.use(router)

//创建本地数据库
const storeInstance = localforage.createInstance({
    name: 'gmwframework',
    storeName: env.storeName || 'gmwframework'
});
//保存本地clientId
storeInstance.getItem(env.gmwframeworkId).then(data => {
    if (!data) {
        data = utils.uuid();
        storeInstance.setItem(env.gmwframeworkId, data);
    }
});

Vue.config.productionTip = false
Vue.prototype.$store = store;
Vue.prototype.$message = Message;
Vue.prototype.$notify = Notification;
Vue.prototype.$watermark = watermark;
Vue.prototype.$request = api
Vue.prototype.$login = login
Vue.prototype.$utils = utils
Vue.prototype.$dayjs = dayjs
Vue.prototype.$env = env;
Vue.prototype.$storeInstance = storeInstance;
App.mpType = 'app'
const app = new Vue({
    ...App
})
// 开启百度统计
if (env.baiduStatisticsKey) {
    var _hmt = _hmt || [];
    window._hmt = _hmt; // 修改为window 全局变量
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?" + env.baiduStatisticsKey;
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
}

//v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
// #ifdef H5
RouterMount(app, router, '#app')
// #endif

// #ifndef H5
app.$mount(); //为了兼容小程序及app端必须这样写才有效果
// #endif
